Always initialise a swiotlb for domain0. Make it a small
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sat, 3 Dec 2005 18:09:19 +0000 (19:09 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Sat, 3 Dec 2005 18:09:19 +0000 (19:09 +0100)
aperture (2MB) for small systems (< 2GB).

Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c

index 7ec30325dd6f28d8f6a1f1f253b5399a8da8cd50..dd7204ad61c1b5e4ac433eb46b293fb5ea43290f 100644 (file)
@@ -43,7 +43,7 @@
  */
 #define IO_TLB_SHIFT 11
 
-int swiotlb_force;
+static int swiotlb_force;
 static char *iotlb_virt_start;
 static unsigned long iotlb_nslabs;
 
@@ -101,10 +101,13 @@ setup_io_tlb_npages(char *str)
                ++str;
        /*
          * NB. 'force' enables the swiotlb, but doesn't force its use for
-         * every DMA like it does on native Linux.
+         * every DMA like it does on native Linux. 'off' forcibly disables
+         * use of the swiotlb.
          */
        if (!strcmp(str, "force"))
                swiotlb_force = 1;
+       else if (!strcmp(str, "off"))
+               swiotlb_force = -1;
        return 1;
 }
 __setup("swiotlb=", setup_io_tlb_npages);
@@ -179,23 +182,21 @@ void
 swiotlb_init(void)
 {
        long ram_end;
+       size_t defsz = 64 * (1 << 20); /* 64MB default size */
 
-       /* The user can forcibly enable swiotlb. */
-       if (swiotlb_force)
+       if (swiotlb_force == 1) {
                swiotlb = 1;
-
-       /*
-         * Otherwise, enable for domain 0 if the machine has 'lots of memory',
-         * which we take to mean more than 2GB.
-         */
-       if (xen_start_info->flags & SIF_INITDOMAIN) {
+       } else if ((swiotlb_force != -1) &&
+                  (xen_start_info->flags & SIF_INITDOMAIN)) {
+               /* Domain 0 always has a swiotlb. */
                ram_end = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
-               if (ram_end > 0x7ffff)
-                       swiotlb = 1;
+               if (ram_end <= 0x7ffff)
+                       defsz = 2 * (1 << 20); /* 2MB on <2GB on systems. */
+               swiotlb = 1;
        }
 
        if (swiotlb)
-               swiotlb_init_with_default_size(64 * (1<<20));
+               swiotlb_init_with_default_size(defsz);
        else
                printk(KERN_INFO "Software IO TLB disabled\n");
 }